import com.spj.entity.User;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import com.spj.service.impl.ServiceImpl;

import java.util.List;

/**
 * @author :spj
 * @description:
 */
public class Test {
    public static void main(String[] args) throws Exception {
//        原始jdbc
//        ApplicationContext applicationContext=new ClassPathXmlApplicationContext("springConfig.xml");
//        SqlSessionFactory sqlSessionFactory = applicationContext.getBean("sqlSessionFactory", SqlSessionFactory.class);
//        Connection connection = sqlSessionFactory.openSession().getConnection();
//        PreparedStatement preparedStatement = connection.prepareStatement("select * from a");
//        ResultSet resultSet = preparedStatement.executeQuery();
//        while (resultSet.next()){
//            System.out.println(resultSet.getInt(1)+"--"+resultSet.getString(2));
//        }
//        接口的方式
//        ApplicationContext applicationContext=new ClassPathXmlApplicationContext("springConfig.xml");
//        testDao testDao = applicationContext.getBean("testDao", testDao.class);
//        List<User> all = testDao.getAll();
//        System.out.println(all);
//          注解的方式
        ApplicationContext applicationContext=new ClassPathXmlApplicationContext("springConfig.xml");
        ServiceImpl serviceImpl = applicationContext.getBean("serviceImpl",ServiceImpl.class);
        List<User> all = serviceImpl.getAll();
        System.out.println(all);
    }
}
